package org.hwadee.service;

import org.hwadee.entity.Category;
import org.hwadee.entity.Post;
import org.hwadee.mapper.CategoryMapper;
import org.springframework.beans.factory.annotation.Autowired;
import org.springframework.stereotype.Service;

import java.util.List;

@Service
public class CategoryService {

    @Autowired
    private CategoryMapper categoryMapper;

    public List<Category> getAllCategories() {
        return categoryMapper.getAllCategories("公告");
    }



    public void insertCategory(Category category) {
        categoryMapper.insertCategory(category);
    }

    public void deleteCategory(Category category) {
        categoryMapper.deleteCategory(category);
    }

    public Integer getCategoryIdByPostId(Integer postId) {
        return categoryMapper.getCategoryIdByPostId(postId);
    }

    public Category getCategoryById(Integer id) {
        return categoryMapper.getCategoryById(id);
    }

    public void updateCategory(Category category) {
        categoryMapper.updateCategory(category);
    }

    public Post getCategoryByCategoryName(String str) {
        return categoryMapper.getCategoryByCategoryName(str);
    }

    public Category getNotice() {
        return categoryMapper.getNotice("公告");
    }


}
